home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #14
/
Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO
/
prog_d
/
isamexpt.zip
/
ISAMEDIT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-01-13
|
49KB
|
1,311 lines
unit Isamedit;
interface
uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
StdCtrls, Dialogs, IsamTabl, IStreams;
type
TEditorExperte = class(TForm)
OKBtn: TBitBtn;
CancelBtn: TBitBtn;
GroupBox2: TGroupBox;
EdiFontLabel: TLabel;
EdiInputFontLabel: TLabel;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
GroupBox6: TGroupBox;
LabelNebenRadio: TRadioButton;
LabelueberRadio: TRadioButton;
GroupBox7: TGroupBox;
LenFestRadio: TRadioButton;
LenVarRadio: TRadioButton;
FontDialog1: TFontDialog;
GroupBox1: TGroupBox;
FormNameInput: TEdit;
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
function CreateSource(const UnitIdent, FormIdent: string): TMemoryStream;
function CreateForm(const FormIdent: string): TMemoryStream;
public
FTable: TIsamTable;
FormIdent,UnitIdent,FileName: String;
constructor Create(AOwner: TComponent); override;
destructor destroy; override;
end;
var
EditorExperte: TEditorExperte;
implementation
{$R *.DFM}
Uses SysUtils, ExtCtrls, Proxies, ExptIntf, UToolDll,
Db, ToolIntf;
Const SourceBufferSize = 4096;
var SourceBuffer: PChar;
procedure FmtWrite(Stream: TStream; Fmt: PChar;
const Args: array of const);
begin
if (Stream <> nil) and (SourceBuffer <> nil) then
begin
StrLFmt(SourceBuffer, SourceBufferSize, Fmt, Args);
Stream.Write(SourceBuffer[0], StrLen(SourceBuffer));
end;
end;
Function GetFieldTypEditor(S: String;
var FieldName: String;
var FieldDataType: TFieldType;
var Len: Integer): Byte;
var G: Byte;
Code: Integer;
SStr: String;
begin
SStr:= UpperCase(S);
if Pos('DATUM',SStr) > 0 then begin
G:= 1;
FieldDataType:= ftDate;
Len:= 10;
end
else if (Pos('REAL',SStr) > 0) or (Pos('INTEGER',SStr) > 0)
or (Pos('BYTE',SStr) > 0) or (Pos('WORD',SStr) > 0)
or (Pos('LONGINT',SStr) > 0) then begin
G:= 2;
if Pos('REAL',SStr) > 0 then begin
FieldDataType:= ftFLOAT;
Len:= 10;
end
else if Pos('INTEGER',SStr) > 0 then begin
FieldDataType:= ftSMALLINT;
Len:= 8;
end
else if Pos('BYTE',SStr) > 0 then begin
FieldDataType:= ftSMALLINT;
Len:= 4;
end
else if Pos('WORD',SStr) > 0 then begin
FieldDataType:= ftWORD;
Len:= 8;
end
else begin
FieldDataType:= ftINTEGER;
Len:= 12;
end;
end
else if (Pos('MEMO',SStr) > 0) then begin
G:= 3;
FieldDataType:= ftMEMO;
Len:= 255;
end
else begin
G:= 0;
FieldDataType:= ftString;
Strip(SStr);
Len:= 255;
if Pos('[',SStr) > 0 then begin
Delete(SStr,1,Pos('[',SStr));
if Pos(']',SStr) > 0 then begin
SStr:= Copy(SStr,1,Pos(']',SStr)-1);
Val(SStr,Len,Code);
end;
end;
end;
Strip(S);
FieldName:= Copy(S,1,Pos(':',S)-1);
GetFieldTypEditor:= G;
end;
function Erzeuge_EditorForm(const FormIdent: string;
SrcTable: TIsamTable;
Label_Neben_Input: Boolean;
InputLen_Fest: Boolean;
LFont, EFont: TFont): TForm;
var
BtnPos : TPoint;
Method : TMethod;
MP,UP,UP1,UP2,UP3: TPanel;
SP : TSpeedButton;
Tbl : TIsamTable;
W,i,Ty,G : Integer;
SLab : TLabel;
{$IFDEF SHAREWARE}
SInp : TOvcSimpleField;
PInp : TOvcPictureField;
NInp : TOvcNumericField;
{$ELSE}
SInp : TEdit;
PInp : TEdit;
NInp : TEdit;
{$ENDIF}
MInp : TMemo;
Tm : TTimer;
FieldName,SStr: String;
Len : Integer;
FieldDataType: TFieldType;
begin
Result := TProxyForm.CreateAs('T' + FormIdent);
with Result do begin
BorderStyle := bsDialog;
AutoScroll := True;
Left:= 100;
Top:= 101;
Width := 400;
Height := 282;
Position := poScreenCenter;
Name := FormIdent;
Caption := FormIdent;
Method.Code := TProxyForm(Result).CreateMethod('FormCreate');
Method.Data := Result;
OnCreate := TNotifyEvent(Method);
with Font do begin
Color := clBlack;
Height:= -11;
Name := 'Arial';
Size := 8;
Style:= [fsBold];
end;
{$IFDEF SHAREWARE}
With TOvcController.Create(Result) do begin
Name:= 'DefaultController';
end;
{$ENDIF}
MP:= TPanel.Create(Result);
with MP do begin
Parent := Result;
Name := 'Panel1';
Align := alTop;
ShowHint:= True;
Caption:= '';
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 10;
Top := 8;
Width := 25;
Height := 25;
Hint := 'Zurⁿck';
Name := 'RueckBttn';
Glyph.Handle:= LoadBitmap(HInstance,'RUECK');
Method.Code := TProxyForm(Result).CreateMethod('RueckBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 35;
Top := 8;
Width := 25;
Height := 25;
Hint := 'VorwΣrts';
Name := 'VorBttn';
Glyph.Handle:= LoadBitmap(HInstance,'VOR');
Method.Code := TProxyForm(Result).CreateMethod('VorBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 60;
Top := 8;
Width := 25;
Height := 25;
Hint := 'Suchen';
Name := 'SuchBttn';
Glyph.Handle:= LoadBitmap(HInstance,'SUCH');
Method.Code := TProxyForm(Result).CreateMethod('SuchBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 85;
Top := 8;
Width := 25;
Height := 25;
Hint := 'Sortierordnung';
Name := 'KeyBttn';
Glyph.Handle:= LoadBitmap(HInstance,'KEY');
Method.Code := TProxyForm(Result).CreateMethod('KeyBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 110;
Top := 8;
Width := 25;
Height := 25;
Hint := 'Leeren';
Name := 'NeuBttn';
Glyph.Handle:= LoadBitmap(HInstance,'NEU');
Method.Code := TProxyForm(Result).CreateMethod('NeuBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 135;
Top := 8;
Width := 25;
Height := 25;
Hint := 'Anlegen';
Name := 'AnlegBttn';
Glyph.Handle:= LoadBitmap(HInstance,'ANLEGEN');
Method.Code := TProxyForm(Result).CreateMethod('AnlegBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 160;
Top := 8;
Width := 25;
Height := 25;
Hint := '─ndern';
Name := 'AendernBttn';
Glyph.Handle:= LoadBitmap(HInstance,'AENDERN');
Method.Code := TProxyForm(Result).CreateMethod('AendernBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 185;
Top := 8;
Width := 25;
Height := 25;
Hint := 'L÷schen';
Name := 'LoeschBttn';
Glyph.Handle:= LoadBitmap(HInstance,'LOESCHEN');
Method.Code := TProxyForm(Result).CreateMethod('LoeschBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 215;
Top := 8;
Width := 25;
Height := 25;
Hint := 'Ok';
Name := 'OkBttn';
Glyph.Handle:= LoadBitmap(HInstance,'OK');
Method.Code := TProxyForm(Result).CreateMethod('OkBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 358;
Top := 8;
Width := 25;
Height := 25;
Hint := 'Ende';
Name := 'AbbruchBttn';
Glyph.Handle:= LoadBitmap(HInstance,'ENDE');
Method.Code := TProxyForm(Result).CreateMethod('AbbruchBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
UP:= TPanel.Create(Result);
with UP do begin
Parent := Result;
Name := 'Panel2';
Align := alBottom;
BevelInner:= bvLowered;
Height:= 27;
ShowHint:= False;
Caption:= '';
end;
UP1:= TPanel.Create(Result);
With UP1 do begin
Parent:= UP;
Left := 308;
Top := 2;
Width := 108;
Height:= 23;
Align := alRight;
BevelOuter := bvLowered;
Font.Color := clBlack;
Font.Height := -11;
Font.Name := 'Arial';
Font.Style := [];
Name:= 'ZeitPanel';
Caption:= '';
end;
UP3:= TPanel.Create(Result);
with UP3 do begin
Parent:= UP;
Left := 2;
Top := 2;
Width := 186;
Height:= 23;
Align := alClient;
ShowHint:= True;
BevelInner := bvLowered;
BevelOuter := bvNone;
Font.Color := clBlack;
Font.Height := -11;
Font.Name := 'Arial';
Font.Style := [];
Name:= 'HintPanel';
Caption:= '';
end;
Tm:= TTimer.Create(Result);
With Tm do begin
Interval:= 1000;
Name:= FormIdent+'Timer';
Method.Code := TProxyForm(Result).CreateMethod(FormIdent+'TimerTimer');
Method.Data := Result;
Tm.OnTimer := TNotifyEvent(Method);
end;
Tbl:= TIsamTable.Create(Result);
with Tbl do begin
Name:= FormIdent+'TABLE';
TableName := '';
end;
if SrcTable.IsamRecord.Count > 0 then begin
Ty:= 52;
For i:= 0 to SrcTable.IsamRecord.Count - 1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
if Label_Neben_Input = False then Inc(Ty,18);
if InputLen_Fest then W:= 130 else W:= 8 * (Len - 1);
if W < 30 then W:= 30;
{$IFDEF SHAREWARE}
Case G of
1: begin
PInp:= TOvcPictureField.Create(Result);
with PInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := W;
Height := 21;
Cursor := crIBeam;
HighlightColors.BackColor := clHighlight;
HighlightColors.TextColor := clHighlightText;
HighlightColors.UseDefault := False;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := EFont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
if FieldDataType = ftTime then begin
DataType := pftTime;
MaxLength:= 5;
PictureMask:= 'hh:mm';
RangeHi:= '23:59';
RangeLo:= '00:00';
end
else begin
DataType:= pftDate;
MaxLength:= 10;
PictureMask := 'dd/mm/yyyy';
end;
end;
end;
2: begin
SInp:= TOvcSimpleField.Create(Result);
with SInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := W;
Height := 21;
Cursor := crIBeam;
HighlightColors.BackColor := clHighlight;
HighlightColors.TextColor := clHighlightText;
HighlightColors.UseDefault := False;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := EFont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
Case FieldDataType of
ftInteger : DataType:= sftLongint;
ftSmallInt: DataType:= sftShortInt;
ftWord : DataType:= sftWord;
else begin
DataType:= sftReal;
DecimalPlaces:= 2;
end;
end;
end;
end;
3: begin
MInp:= TMemo.Create(Result);
with MInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := 130;
Height := 89;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := Efont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
end;
end;
else begin
SInp:= TOvcSimpleField.Create(Result);
with SInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := W;
Height := 21;
Cursor := crIBeam;
HighlightColors.BackColor := clHighlight;
HighlightColors.TextColor := clHighlightText;
HighlightColors.UseDefault := False;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := EFont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
DataType := sftString;
MaxLength := Len;
PictureMask := 'X';
end;
end;
end;
{$ELSE}
Case G of
1: begin
PInp:= TEdit.Create(Result);
with PInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := W;
Height := 21;
Cursor := crIBeam;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := EFont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
if FieldDataType = ftTime then begin
MaxLength:= 5;
end
else begin
MaxLength:= 10;
end;
end;
end;
2: begin
SInp:= TEdit.Create(Result);
with SInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := W;
Height := 21;
Cursor := crIBeam;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := EFont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
end;
end;
3: begin
MInp:= TMemo.Create(Result);
with MInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := 130;
Height := 89;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := Efont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
end;
end;
else begin
SInp:= TEdit.Create(Result);
with SInp do begin
Name:= FieldName + 'Input';
Parent:= Result;
if Label_Neben_Input then Left:= 100 else Left:= 20;
Top := Ty;
Width := W;
Height := 21;
Cursor := crIBeam;
Font.Color := EFont.Color;
Font.Height := EFont.Height;
Font.Name := EFont.Name;
Font.Style := EFont.Style;
ParentColor := False;
TabStop := True;
MaxLength:= Len;
end;
end;
end;
{$ENDIF}
if Label_Neben_Input = False then Dec(Ty,18);
SLab:= TLabel.Create(Result);
With SLab do begin
Name:= FieldName+'Label';
Parent:= Result;
Caption:= FieldName;
Left:= 20;
Top:= Ty + 2;
Font.Color := LFont.Color;
Font.Height := LFont.Height;
Font.Name := LFont.Name;
Font.Style := LFont.Style;
end;
Ty:= Ty+24;
if Label_Neben_Input = False then Inc(Ty,20);
if G = 3 then Ty:= Ty + 68;
end;
end;
end;
end;
end;
function Erzeuge_EditorSource(const UnitIdent, FormIdent: string;
SrcTable: TIsamTable): TMemoryStream;
const
CRLF = #13#10;
Var I,Len: integer;
G: Byte;
FieldDataType: TFieldType;
FieldName,NStr,SStr : String;
begin
SourceBuffer := StrAlloc(SourceBufferSize);
try
Result := TMemoryStream.Create;
try
{ unit header and uses clause }
FmtWrite(Result,
'unit %s;' + CRLF + CRLF +
'interface' + CRLF + CRLF +
'uses'#13#10 +
' SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,'#13#10 +
' StdCtrls, ExtCtrls, Forms', [UnitIdent]);
FmtWrite(Result,
',Inp_Tool, Buttons,'+CRLF,[NIL]);
{$IFDEF SHAREWARE}
if NormInputs then begin
FmtWrite(Result,
'OvcPb, OvcNf, OvcBase, OvcEf, OvcSf, OvcPf,'+CRLF,[NIL]);
end;
{$ENDIF}
FmtWrite(Result,
' IsamTabl;' + CRLF + CRLF, [nil]);
{ begin the class declaration }
if SrcTable.IsamRecord.Count > 0 then begin
For i:= 0 to SrcTable.IsamRecord.Count - 1 do begin
FmtWrite(Result,' %s'+CRLF,[SrcTable.IsamRecord[i]]);
end;
end;
FmtWrite(Result,
'type'#13#10 +
' T%s = class(TForm)'#13#10, [FormIdent]);
FmtWrite(Result,
' Panel1 : TPanel;' + CRLF +
' Panel2 : TPanel;' + CRLF +
' ZeitPanel: TPanel;'+ CRLF +
' HintPanel: TPanel;'+ CRLF +
' %sTimer : TTimer;'+ CRLF,[FormIdent]);
FmtWrite(Result,
' RueckBttn: TSpeedButton;' + CRLF +
' VorBttn: TSpeedButton;' + CRLF +
' SuchBttn: TSpeedButton;' + CRLF +
' KeyBttn: TSpeedButton;' + CRLF +
' NeuBttn: TSpeedButton;' + CRLF,[NIL]);
FmtWrite(Result,
' AnlegBttn: TSpeedButton;' + CRLF +
' AendernBttn: TSpeedButton;' + CRLF,[NIL]);
FmtWrite(Result,
' LoeschBttn: TSpeedButton;' + CRLF +
' OkBttn: TSpeedButton;' + CRLF +
' AbbruchBttn: TSpeedButton;' + CRLF, [NIL]);
FmtWrite(Result,
' %sTable: TIsamTable;'+CRLF,[FormIdent]);
{$IFDEF SHAREWARE}
if Norminputs then
FmtWrite(Result,' DefaultController: TOvcController;'+CRLF,[NIL]);
{$ENDIF}
if SrcTable.IsamRecord.Count > 0 then begin
For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
{$IFDEF SHAREWARE}
Case G of
1: FmtWrite(Result,
' %sInput: TOvcPictureField;'+CRLF+
' %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
2: FmtWrite(Result,
' %sInput: TOvcSimpleField;'+CRLF+
' %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
3: FmtWrite(Result,
' %sInput: TMemo;'+CRLF+
' %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
else FmtWrite(Result,
' %sInput: TOvcSimpleField;'+CRLF+
' %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
end;
{$ELSE}
Case G of
1: FmtWrite(Result,
' %sInput: TEdit;'+CRLF+
' %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
2: FmtWrite(Result,
' %sInput: TEdit;'+CRLF+
' %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
3: FmtWrite(Result,
' %sInput: TMemo;'+CRLF+
' %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
else FmtWrite(Result,
' %sInput: TEdit;'+CRLF+
' %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
end;
{$ENDIF}
end;
end;
end;
FmtWrite(Result,
' procedure FormCreate(Sender: TObject);' + CRLF +
' procedure VorBttnClick(Sender: TObject);' + CRLF +
' procedure RueckBttnClick(Sender: TObject);' + CRLF +
' procedure NeuBttnClick(Sender: TObject);' + CRLF +
' procedure OkBttnClick(Sender: TObject);' + CRLF,[NIL]);
FmtWrite(Result,
' procedure AbbruchBttnClick(Sender: TObject);' + CRLF,[NIL]);
FmtWrite(Result,
' procedure AendernBttnClick(Sender: TObject);' + CRLF +
' procedure AnlegBttnClick(Sender: TObject);' + CRLF,[NIL]);
FmtWrite(Result,
' procedure LoeschBttnClick(Sender: TObject);' + CRLF +
' procedure SuchBttnClick(Sender: TObject);' + CRLF +
' procedure KeyBttnClick(Sender: TObject);' + CRLF, [NIL]);
FmtWrite(Result,
' Procedure ShowHint(Sender: TObject); ' + CRLF +
' Procedure %sTimerTimer(Sender: TObject);' + CRLF +
' private'+CRLF,[FormIdent]);
FmtWrite(Result,
' Function IsModified: Boolean;' + CRLF +
' Procedure ResetModified;' + CRLF,[NIL]);
FmtWrite(Result,
' public' + CRLF,[NIL]);
FmtWrite(Result,
' Procedure SetData;' + CRLF +
' Procedure LeerData;' + CRLF +
' Procedure GetData;' + CRLF,
[nil]);
FmtWrite(Result,
' end;' + CRLF + CRLF +
'var' + CRLF +
' %s: T%s;' + CRLF + CRLF,[FormIdent, FormIdent]);
FmtWrite(Result,
' %sData,%sDup: %s;' + CRLF + CRLF,[SrcTable.RecordName,SrcTable.RecordName,SrcTable.RecordName]);
FmtWrite(Result,
'implementation' + CRLF + CRLF +
'Uses UToolDll, UBrwTool, Isam_Key;' + CRLF + CRLF +
'{$R *.DFM}' + CRLF + CRLF, [NIL]);
FmtWrite(Result,
'procedure T%s.FormCreate(Sender: TObject);' + CRLF +
'begin' + CRLF +
' Application.OnHint:= ShowHint;' + CRLF,[FormIdent]);
FmtWrite(Result,
'end;' + CRLF + CRLF,[NIL]);
FmtWrite(Result,
'Function T%s.IsModified: Boolean;' + CRLF +
'var M: Boolean;' + CRLF +
' i: Integer;' + CRLF +
'begin' + CRLF +
' M:= False;' + CRLF +
' if ComponentCount > 0 then begin' + CRLF +
' i:= 0;' + CRLF,[FormIdent]);
FmtWrite(Result,
' Repeat' + CRLF +
' if Components[i] is TEdit then begin' + CRLF +
' if TEdit(Components[i]).Modified then M:= True;'+ CRLF +
' end' + CRLF +
' else if Components[i] is TMemo then begin' + CRLF +
' if TMemo(Components[i]).Modified then M:= True;'+ CRLF +
' end' + CRLF,[NIL]);
FmtWrite(Result,
' else if (Components[i] is TInput) then begin' + CRLF +
' if TInput(Components[i]).Modified then M:= True;'+ CRLF,[NIL]);
{$IFDEF SHAREWARE}
FmtWrite(Result,
' end'+CRLF+
' else if (Components[i] is TOvcPictureField) then begin' + CRLF +
' if TOvcPictureField(Components[i]).Modified then M:= True;'+ CRLF +
' end'+CRLF,[NIL]);
FmtWrite(Result,
' else if (Components[i] is TOvcSimpleField) then begin' + CRLF +
' if TOvcSimpleField(Components[i]).Modified then M:= True;' + CRLF +
' end' + CRLF,[NIL]);
FmtWrite(Result,
' else if (Components[i] is TOvcNumericField) then begin' + CRLF +
' if TOvcNumericField(Components[i]).Modified then M:= True;' + CRLF +
' end;' + CRLF,[NIL]);
{$ELSE}
FmtWrite(Result,
' end;'+CRLF,[NIL]);
{$ENDIF}
FmtWrite(Result,
' inc(i);' + CRLF +
' Until (i >= ComponentCount) or (M = True);' + CRLF +
' end;' + CRLF +
' IsModified:= M;' + CRLF +
'end;' + CRLF + CRLF, [NIL]);
FmtWrite(Result,
'procedure T%s.ResetModified;' + CRLF +
'var i: Integer;' + CRLF +
'begin' + CRLF +
' if ComponentCount > 0 then begin' + CRLF +
' i:= 0;' + CRLF, [FormIdent]);
FmtWrite(Result,
' Repeat' + CRLF +
' if Components[i] is TEdit then begin' + CRLF +
' TEdit(Components[i]).Modified:= False;' + CRLF +
' end' + CRLF,[NIL]);
FmtWrite(Result,
' else if Components[i] is TMemo then begin' + CRLF +
' TMemo(Components[i]).Modified:= False;' + CRLF +
' end' + CRLF, [NIL]);
FmtWrite(Result,
' else if (Components[i] is TInput) then begin' + CRLF +
' TInput(Components[i]).Modified:= False;' + CRLF,[NIL]);
{$IFDEF SHAREWARE}
FmtWrite(Result,
' end'+CRLF+
' else if (Components[i] is TOvcPictureField) then begin' + CRLF +
' TOvcPictureField(Components[i]).Modified:= False;'+ CRLF +
' end'+CRLF,[NIL]);
FmtWrite(Result,
' else if (Components[i] is TOvcSimpleField) then begin' + CRLF +
' TOvcSimpleField(Components[i]).Modified:= False;' + CRLF +
' end' + CRLF,[NIL]);
FmtWrite(Result,
' else if (Components[i] is TOvcNumericField) then begin'+ CRLF +
' TOvcNumericField(Components[i]).Modified:= False;'+ CRLF +
' end;' + CRLF,[NIL]);
{$ELSE}
FmtWrite(Result,
' end;' + CRLF,[NIL]);
{$ENDIF}
FmtWrite(Result,
' inc(i);' + CRLF +
' Until (i >= ComponentCount);' + CRLF +
' end;' + CRLF +
'end;' + CRLF + CRLF, [NIL]);
FmtWrite(Result,
'Procedure T%s.SetData;' + CRLF +
'begin' + CRLF+
' Fillchar(%sData,Sizeof(%sData),0);'+CRLF+
' %sTable.Get(%sData,%sDup);'+CRLF,[FormIdent,
SrcTable.RecordName,SrcTable.RecordName,FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
{$IFDEF SHAREWARE}
if SrcTable.IsamRecord.Count > 0 then begin
FmtWrite(Result,' with %sData do begin'+CRLF,[SrcTable.Recordname]);
For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
case FieldDataType of
ftSmallInt: FmtWrite(Result,
' %sInput.AsInteger:= %s;'+CRLF,[FieldName,FieldName]);
ftInteger : FmtWrite(Result,
' %sInput.AsLongint:= %s;'+CRLF,[FieldName,FieldName]);
ftWord : FmtWrite(Result,
' %sInput.AsLongint:= %s;'+CRLF,[FieldName,FieldName]);
ftFloat : FmtWrite(Result,
' %sInput.AsFloat:= %s;'+CRLF,[FieldName,FieldName]);
ftMemo : FmtWrite(Result,
' %sInput.Assign(%s;'+CRLF,[FieldName,FieldName]);
else FmtWrite(Result,
' %sInput.AsString:= %s;'+CRLF,[FieldName,FieldName]);
end;
end;
end;
FmtWrite(Result,' end;'+CRLF,[NIL]);
end;
{$ELSE}
if SrcTable.IsamRecord.Count > 0 then begin
FmtWrite(Result,' with %sData do begin'+CRLF,[SrcTable.Recordname]);
For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
case FieldDataType of
ftSmallInt: FmtWrite(Result,
' %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
ftInteger : FmtWrite(Result,
' %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
ftWord : FmtWrite(Result,
' %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
ftFloat : FmtWrite(Result,
' %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
ftMemo : FmtWrite(Result,
' %sInput.Assign(%s);'+CRLF,[FieldName,FieldName]);
else FmtWrite(Result,
' %sInput.Text:= %s;'+CRLF,[FieldName,FieldName]);
end;
end;
end;
FmtWrite(Result,' end;'+CRLF,[NIL]);
end;
{$ENDIF}
FmtWrite(Result,
' {AnlegBttn.Enabled:= False;}' + CRLF +
' {AendernBttn.Enabled:= True;}' + CRLF +
' {LoeschBttn.Enabled:= True;}' + CRLF +
' ResetModified;' + CRLF +
'end;'+ CRLF + CRLF, [NIL]);
FmtWrite(Result,
'Procedure T%s.GetData;' + CRLF +
'var Code: Integer;'+ CRLF+
'begin' + CRLF,[FormIdent]);
{$IFDEF SHAREWARE}
if SrcTable.IsamRecord.Count > 0 then begin
FmtWrite(Result,' Fillchar(%sData,Sizeof(%sData),0);'+CRLF,[SrcTable.RecordName,SrcTable.RecordName]);
FmtWrite(Result,' with %sData do begin'+CRLF,[SrcTable.Recordname]);
For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
Case FieldDataType of
ftSmallInt: FmtWrite(Result,
' %s:= %sInput.AsInteger;'+CRLF,[FieldName,FieldName]);
ftInteger : FmtWrite(Result,
' %s:= %sInput.AsLongint;'+CRLF,[FieldName,FieldName]);
ftWord : FmtWrite(Result,
' %s:= %sInput.AsInteger;'+CRLF,[FieldName,FieldName]);
ftFloat : FmtWrite(Result,
' %s:= %sInput.AsFloat;'+CRLF,[FieldName,FieldName]);
ftMemo : FmtWrite(Result,
' %s.Assign(%sInput.Strings);' + CRLF,[FieldName,FieldName]);
else FmtWrite(Result,
' %s:= %sInput.AsString;'+CRLF,[FieldName,FieldName]);
end;
end;
end;
FmtWrite(Result,' end;'+CRLF,[NIL]);
end;
{$ELSE}
if SrcTable.IsamRecord.Count > 0 then begin
FmtWrite(Result,' Fillchar(%sData,Sizeof(%sData),0);'+CRLF,[SrcTable.RecordName,SrcTable.RecordName]);
FmtWrite(Result,' with %sData do begin'+CRLF,[SrcTable.Recordname]);
For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
Case FieldDataType of
ftSmallInt: FmtWrite(Result,
' Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
ftInteger : FmtWrite(Result,
' Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
ftWord : FmtWrite(Result,
' Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
ftFloat : FmtWrite(Result,
' Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
ftMemo : FmtWrite(Result,
' %s.Assign(%sInput.Strings);' + CRLF,[FieldName,FieldName]);
else FmtWrite(Result,
' %s:= %sInput.Text;'+CRLF,[FieldName,FieldName]);
end;
end;
end;
FmtWrite(Result,' end;'+CRLF,[NIL]);
end;
{$ENDIF}
FmtWrite(Result,
'end;' + CRLF + CRLF, [NIL]);
FmtWrite(Result,
'Procedure T%s.LeerData;' + CRLF +
'begin' + CRLF,[FormIdent]);
{$IFDEF SHAREWARE}
if SrcTable.IsamRecord.Count > 0 then begin
For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
Case FieldDataType of
ftSmallInt: FmtWrite(Result,
' %sInput.AsInteger:= 0;'+ CRLF,[F.FieldName]);
ftInteger : FmtWrite(Result,
' %sInput.AsLongint:= 0;'+ CRLF,[F.FieldName]);
ftFloat : FmtWrite(Result,
' %sInput.AsFloat:= 0;'+ CRLF,[F.FieldName]);
ftMemo : FmtWrite(Result,
' %sInput.Strings.Clear;'+ CRLF,[F.FieldName]);
else FmtWrite(Result,
' %sInput.AsString:= '+Chr(39)+ Chr(39)+';'+CRLF,[F.FieldName]);
end;
{$ELSE}
if SrcTable.IsamRecord.Count > 0 then begin
For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
SStr:= SrcTable.IsamRecord[i];
if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
Case FieldDataType of
ftSmallInt: FmtWrite(Result,
' %sInput.Text:= '+Chr(39)+'0'+Chr(39)+';'+ CRLF,[FieldName]);
ftInteger : FmtWrite(Result,
' %sInput.Text:= '+Chr(39)+'0'+Chr(39)+';'+ CRLF,[FieldName]);
ftFloat : FmtWrite(Result,
' %sInput.Text:= '+Chr(39)+'0.00'+Chr(39)+';'+ CRLF,[FieldName]);
ftMemo : FmtWrite(Result,
' %sInput.Strings.Clear;'+ CRLF,[FieldName]);
else FmtWrite(Result,
' %sInput.Text:= '+Chr(39)+ Chr(39)+';'+CRLF,[FieldName]);
end;
end;
end;
end;
{$ENDIF}
FmtWrite(Result,
' {AnlegBttn.Enabled:= True;}' + CRLF +
' {AendernBttn.Enabled:= False;}' + CRLF +
' {LoeschBttn.Enabled:= False;}' + CRLF +
'end;' + CRLF + CRLF, [NIL]);
FmtWrite(Result,
'procedure T%s.VorBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF,[FormIdent]);
FmtWrite(Result,
' if (IsModified) then begin' + CRLF +
' if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+','+Chr(39)+'Trotzdem weiter ?'+Chr(39)+
') = False then Exit;' + CRLF +
' end;' + CRLF +
' %sTable.Next(%sData,%sDup);' + CRLF +
' SetData;' + CRLF +
'end;' + CRLF + CRLF, [FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
FmtWrite(Result,
'procedure T%s.RueckBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF,[FormIdent]);
FmtWrite(Result,
' if (IsModified) then begin' + CRLF +
' if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+','+Chr(39)+'Trotzdem weiter ?'+Chr(39)+
') = False then Exit;' + CRLF +
' end;' + CRLF +
' %sTable.Prior(%sData,%sDup);' + CRLF +
' SetData;' + CRLF +
'end;'+ CRLF + CRLF, [FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
FmtWrite(Result,
'procedure T%s.NeuBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF,[FormIdent]);
FmtWrite(Result,
' if (IsModified) then begin' + CRLF +
' if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+','+Chr(39)+'Trotzdem weiter ?'+Chr(39)+
') = False then Exit;' + CRLF +
' end;' + CRLF +
' LeerData;' + CRLF +
'end;'+ CRLF + CRLF, [NIL]);
NStr:= 'ModalResult:= mrOK';
FmtWrite(Result,
'procedure T%s.OkBttnClick(Sender: TObject);' + CRLF +
'var Txt: String;'+ CRLF +
'begin' + CRLF,[FormIdent]);
FmtWrite(Result,
' if IsModified then begin' + CRLF +
' if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+
','+Chr(39)+'Trotzdem beenden ?'+Chr(39)+')' + CRLF +
' then ModalResult:= mrOk' + CRLF +
' else Exit;' + CRLF +
' end' + CRLF +
' else %s;' + CRLF+
'end;'+ CRLF + CRLF, [NStr]);
NStr:= 'ModalResult:= mrCancel';
FmtWrite(Result,
'procedure T%s.AbbruchBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF,[FormIdent]);
FmtWrite(Result,
' %s;' + CRLF +
'end;'+ CRLF + CRLF, [NStr]);
FmtWrite(Result,
'procedure T%s.AendernBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF +
' GetData;' + CRLF +
' %sTable.UpdateRecord(%sData,%sDup);' + CRLF +
' ResetModified;' + CRLF +
'end;' + CRLF + CRLF,[FormIdent,FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
FmtWrite(Result,
'procedure T%s.AnlegBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF +
' GetData;' + CRLF +
' %sTable.Insert(%sData,%sDup);' + CRLF +
' {AnlegBttn.Enabled:= False;}' + CRLF +
' {AendernBttn.Enabled:= True;}' + CRLF +
' {LoeschBttn.Enabled:= True;}' + CRLF +
' ResetModified;' + CRLF +
'end;' + CRLF + CRLF,[FormIdent,FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
FmtWrite(Result,
'procedure T%s.LoeschBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF +
' GetData;' + CRLF +
' %sTable.Delete(%sData,%sDup);' + CRLF +
' {LoeschBttn.Enabled:= not(%stable.Eof);}'+ CRLF,[FormIdent,FormIdent,SrcTable.RecordName,
SrcTable.RecordName,FormIdent]);
FmtWrite(Result,
' {AnlegBttn.Enabled:= True;}' + CRLF +
' {AendernBttn.Enabled:= False;}' + CRLF +
' ResetModified;' + CRLF +
'end;'+ CRLF + CRLF, [NIL]);
FmtWrite(Result,
'procedure T%s.SuchBttnClick(Sender: TObject);' + CRLF +
'begin' + CRLF +
' {}' + CRLF +
' SetData;' + CRLF +
'end;'+ CRLF + CRLF, [FormIdent]);
FmtWrite(Result,
'procedure T%s.KeyBttnClick(Sender: TObject);' + CRLF +
'var Liste: TStringList;'+ CRLF+
' Key1: Integer;'+CRLF,[FormIdent]);
FmtWrite(Result,
'begin'+CRLF+
' Key1:= %sTable.KeyNo;'+CRLF+
' Liste:= TStringList.Create;'+CRLF,[FormIdent]);
if SrcTable.IsamKeyProc.Count > 0 then begin
For i:= 0 to SrcTable.IsamKeyProc.Count-1 do begin
NStr:= SrcTable.IsamKeyProc[i];
if Pos('S:=',NStr) > 0 then begin
if Pos('(',NStr) > 0 then begin
Delete(NStr,1,Pos('(',NStr));
if Pos(',',NStr) > 0 then begin
NStr:= Copy(NStr,1,Pos(',',NStr)-1);
FmtWrite(Result,
' Liste.Add('+Chr(39)+'%s'+Chr(39)+');'+CRLF,[NStr]);
end;
end;
end;
end;
end;
FmtWrite(Result,
' Key_Einstellen(Self,Key1,Liste);'+CRLF,[NIL]);
FmtWrite(Result,
' %sTable.KeyNo:= Key1;'+CRLF+
' Liste.Free;'+CRLF+
'end;'+ CRLF + CRLF, [FormIdent]);
FmtWrite(Result,
'procedure T%s.%sTimerTimer(Sender: TObject);'+ CRLF +
'var TStr: String;'+CRLF+
'begin'+ CRLF +
' TStr:= '+Chr(39)+Chr(39)+';'+CRLF,[FormIdent,FormIdent]);
FmtWrite(Result,
' DateTimeToString(TStr,'+Chr(39)+'dd.mm.yyyy hh:mm'+Chr(39)+',Now);'+CRLF+
' ZeitPanel.Caption:= TStr;' + CRLF +
'end;'+ CRLF + CRLF, [NIL]);
FmtWrite(Result,
'Procedure T%s.ShowHint(Sender: TObject);' + CRLF +
'begin' + CRLF +
' HintPanel.Caption:= Application.Hint;' + CRLF +
'end;' + CRLF + CRLF,[FormIdent]);
FmtWrite(Result, 'end.' + CRLF, [nil]);
Result.Position := 0;
except
Result.Free;
raise;
end;
finally
StrDispose(SourceBuffer);
end;
end;
Constructor TEditorExperte.Create(AOwner: TComponent);
begin
Inherited Create(aOwner);
FTable:= TIsamTable.Create(Self);
end;
destructor TEditorExperte.destroy;
begin
FTable.Free;
Inherited destroy;
end;
procedure TEditorExperte.SpeedButton5Click(Sender: TObject);
begin
if FontDialog1.Execute then EdiFontLabel.Font:= FontDialog1.Font;
end;
procedure TEditorExperte.SpeedButton6Click(Sender: TObject);
begin
if FontDialog1.Execute then EdiInputFontLabel.Font:= FontDialog1.Font;
end;
function TEditorExperte.CreateForm(const FormIdent: string): TMemoryStream;
var DlgForm: TForm;
begin
Result := nil;
DlgForm := Erzeuge_EditorForm(FormNameInput.Text,
FTable,
LabelNebenRadio.Checked,
LenFestRadio.Checked,
EdiFontLabel.Font,
EdiInputFontLabel.Font);
try
Result := TMemoryStream.Create;
Result.WriteComponentRes(FormIdent, DlgForm);
Result.Position := 0;
finally
DlgForm.Free;
end;
end;
function TEditorExperte.CreateSource(const UnitIdent, FormIdent: string): TMemoryStream;
begin
CreateSource:= Erzeuge_EditorSource(UnitIdent, FormNameInput.Text, FTable);
end;
procedure TEditorExperte.OKBtnClick(Sender: TObject);
var ISourceStream, IFormStream: TIMemoryStream;
begin
if Toolservices = NIL then Exit;
if FormNameInput.Text = '' then Errorwindow('Formname muss angegeben werden','')
else begin
FormIdent:= FormNameInput.Text;
if UnitIdent = '' then begin
Errorwindow('UnitIdent ist nicht angegeben','');
Exit;
end;
if FileName = '' then begin
Errorwindow('Filename ist ungⁿltig','');
Exit;
end;
IFormStream := TIMemoryStream.Create(CreateForm(FormIdent));
try
ISourceStream := TIMemoryStream.Create(CreateSource(UnitIdent, FormIdent));
try
ToolServices.CreateModule(FileName, ISourceStream, IFormStream,
[cmAddToProject, cmShowSource, cmShowForm, cmUnNamed,
cmMarkModified]);
finally
ISourceStream.OwnStream := True;
ISourceStream.Free;
end;
finally
IFormStream.OwnStream := True;
IFormStream.Free;
end;
end;
end;
procedure TEditorExperte.FormShow(Sender: TObject);
begin
if ToolServices = nil then Exit;
if ToolServices.GetNewModuleName(UnitIdent, FileName) then begin
FormIdent:= UnitIdent + 'Dialog';
FormNameInput.Text:= FormIdent;
end;
end;
end.